﻿using DLL.MSDM.Entity.Param;
using DLL.Standard.Infrastructure;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;

namespace DLL.NetStandard.FlushRobot.MS.Entity.Param
{
    [Serializable]
    public class CMS_WorkPointParam : CNotifyPropertyChanged
    {
        //X轴高度
        private double _X_StationPos0;

        public double X_StationPos0
        {
            get { return _X_StationPos0; }
            set { _X_StationPos0 = value; OnPropertyChanged(); }
        }//抽取，溶媒位置

        private double _X_StationPos1;

        public double X_StationPos1
        {
            get { return _X_StationPos1; }
            set { _X_StationPos1 = value; OnPropertyChanged(); }
        }

        private double _X_StationPos2;

        public double X_StationPos2
        {
            get { return _X_StationPos2; }
            set { _X_StationPos2 = value; OnPropertyChanged(); }
        }

        private double _X_StationPos3;

        public double X_StationPos3
        {
            get { return _X_StationPos3; }
            set { _X_StationPos3 = value; OnPropertyChanged(); }
        }

        private double _X_StationPos4;

        public double X_StationPos4
        {
            get { return _X_StationPos4; }
            set { _X_StationPos4 = value; OnPropertyChanged(); }
        }

        //药的数量小于3的放药位置
        private double _X_PutDrugsPos;

        public double X_PutDrugsPos
        {
            get { return _X_PutDrugsPos; }
            set { _X_PutDrugsPos = value; OnPropertyChanged(); }
        }

        //药的数量大于2的放药位置
        private double _X_PutDrugsPos4;

        public double X_PutDrugsPos4
        {
            get { return _X_PutDrugsPos4; }
            set { _X_PutDrugsPos4 = value; OnPropertyChanged(); }
        }//放药品位置

        private double _X_PutSolventPos;

        public double X_PutSolventPos
        {
            get { return _X_PutSolventPos; }
            set { _X_PutSolventPos = value; OnPropertyChanged(); }
        }//放溶媒位置

        private double _X_StationPos7;

        public double X_StationPos7
        {
            get { return _X_StationPos7; }
            set { _X_StationPos7 = value; OnPropertyChanged(); }
        }

        private double _X_YBStartPos;

        public double X_YBStartPos
        {
            get { return _X_YBStartPos; }
            set { _X_YBStartPos = value; OnPropertyChanged(); }
        }//摇晃起始实位置

        private double _X_YBEndPos;

        public double X_YBEndPos
        {
            get { return _X_YBEndPos; }
            set { _X_YBEndPos = value; OnPropertyChanged(); }
        }//摇晃结束位置

        //Y轴高度

        private double _y_SolventHeight;

        public double Y_SolventHeight
        {
            get { return _y_SolventHeight; }
            set { _y_SolventHeight = value; OnPropertyChanged(); }
        }//Y轴-溶媒打入液体高度

        private double _y_FlushHeightHight;

        public double Y_FlushHeightHight
        {
            get { return _y_FlushHeightHight; }
            set { _y_FlushHeightHight = value; OnPropertyChanged(); }
        }//冲配高度

        private double _y_FlushHeightLow;

        public double Y_FlushHeightLow
        {
            get { return _y_FlushHeightLow; }
            set { _y_FlushHeightLow = value; OnPropertyChanged(); }
        }//冲配高度

        private double _y_PumpHeightLow;

        public double Y_PumpHeightLow
        {
            get { return _y_PumpHeightLow; }
            set { _y_PumpHeightLow = value; OnPropertyChanged(); }
        }

        //Y轴-抽液体时能下降的最终高度
        private double _y_PumpHeightHight;

        public double Y_PumpHeightHight
        {
            get { return _y_PumpHeightHight; }
            set { _y_PumpHeightHight = value; OnPropertyChanged(); }
        }//Y轴-抽取液体高度

        private double _y_BottleStartPunctureHeight;

        public double Y_BottleStartPunctureHeight
        {
            get { return _y_BottleStartPunctureHeight; }
            set { _y_BottleStartPunctureHeight = value; OnPropertyChanged(); }
        }//穿刺其实高度

        private double _y_BottleEndPunctureHeight;

        public double Y_BottleEndPunctureHeight
        {
            get { return _y_BottleEndPunctureHeight; }
            set { _y_BottleEndPunctureHeight = value; OnPropertyChanged(); }
        }//穿刺其实高度

        private double _y_SolventStartPunctureHeight;

        public double Y_SolventStartPunctureHeight
        {
            get { return _y_SolventStartPunctureHeight; }
            set { _y_SolventStartPunctureHeight = value; OnPropertyChanged(); }
        }//穿刺其实高度

        private double _y_SafeHeight;

        public double Y_SafeHeight
        {
            get { return _y_SafeHeight; }
            set { _y_SafeHeight = value; OnPropertyChanged(); }
        }//Y轴-移动的安全高度

        private double _z_ReplaceInjectorPos;

        public double Z_ReplaceInjectorPos
        {
            get { return _z_ReplaceInjectorPos; }
            set { _z_ReplaceInjectorPos = value; OnPropertyChanged(); }
        }//Y轴换注射器高度

        public double _X_CleanPos1 = 0;

        public double X_CleanPos1
        {
            get { return _X_CleanPos1; }
            set { _X_CleanPos1 = value; OnPropertyChanged(); }
        }

        public double _X_CleanPos2 = 50;

        public double X_CleanPos2
        {
            get { return _X_CleanPos2; }
            set { _X_CleanPos2 = value; OnPropertyChanged(); }
        }

        public double _X_CleanPos3 = 120;

        public double X_CleanPos3
        {
            get { return _X_CleanPos3; }
            set { _X_CleanPos3 = value; OnPropertyChanged(); }
        }

        public double _Y_CleanPos2 = 50;

        public double Y_CleanPos2
        {
            get { return _Y_CleanPos2; }
            set { _Y_CleanPos2 = value; OnPropertyChanged(); }
        }
    }

    public class CMS_WR_WorkPointParam : CNotifyPropertyChanged
    {
        private string folderPath = @"Param\";

        public CMS_WR_WorkPointParam()
        {
            int devType = 0;
            CWR_MotionCardType wrobj = new CWR_MotionCardType();
            bool ret = wrobj.ReadParam();
            if (true == ret)
            {
                devType = wrobj.Obj.DeviceType;
            }
            else
            {
                devType = 0;
            }
            string deviceName = "";
            deviceName = CMotionCardType.DevTypeName[devType];
            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
            folderPath = str_1 + @"Param\" + deviceName + @"\DeviceParam\";
        }

        private CMS_WorkPointParam _Param = new CMS_WorkPointParam();

        public CMS_WorkPointParam Param
        {
            get { return _Param; }
            set
            {
                if (_Param != value)
                {
                    _Param = value;
                    OnPropertyChanged();
                }
            }
        }

        public bool ReadParam()
        {
            XmlSerializer xmlFormat = new XmlSerializer(typeof(CMS_WorkPointParam));
            //string str2 = Application.StartupPath;
            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
            string filePath = folderPath + "MS_WorkPointParam.xml";
            if (File.Exists(filePath))
            {
                Stream fstream = File.OpenRead(filePath);
                _Param = (CMS_WorkPointParam)xmlFormat.Deserialize(fstream);
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool SaveParam()
        {
            XmlSerializer xmlFormat = new XmlSerializer(typeof(CMS_WorkPointParam));
            //现在将数据保存到本地的一个文件中
            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
            string filePath = folderPath + "MS_WorkPointParam.xml";

            Stream fstream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
            xmlFormat.Serialize(fstream, Param);
            fstream.Close();
            return true;
        }
    }
}